class Prop:
    def __init__(self, attr):
        self._attr = f"_{attr}"
        print(self._attr)

    def get(self, obj):
        if not hasattr(obj, self._attr):
            return None
        return getattr(obj, self._attr)

    def set(self, obj, value):
        setattr(obj, self._attr, value)


class Human(type):
    @staticmethod
    def __new__(cls, *args, **kwargs):
        # cls指Human类，创建出来的my_class类指向Student类
        my_class = super().__new__(cls, *args)
        my_class.freedom = True
        if kwargs:
            for key, value in kwargs.items():
                setattr(my_class, key, value)

        for property_name in my_class.props:
            prop = Prop(property_name)
            p_obj = property(fget=prop.get, fset=prop.set)
            setattr(my_class, property_name, p_obj)

        return my_class


class Student(object, metaclass=Human, country='China', age="18"):
    props = ["name", "gender"]
    pass


student = Student()

print(student.freedom)
print(student.country)
print(student.age)
print(student.name)
student.name = "张三"
print(student.name)
print(student.gender)



